import api from "@/api/bandwidth"
import { Message } from 'iview'

export default {
    state: {  
        customerRelatedomains: [],
        bandwidthDatas: [],
    },
    getters: {  
        customerRelatedomains: state => state.customerRelatedomains, 
        bandwidthDatas: state => state.bandwidthDatas, 
    },
    actions: {  
        fetchCustomerRelateDomain({commit}, condition){ 
            api.fetchCustomerRelateDomain(condition.params).then(reply => { 
                if(reply.data.ok){
                    commit('FETCH_CUSTOMER_RELATE_DOMAIN', reply.data.data);
                    condition.cb && condition.cb()  
                }else{
                    Message.error(reply.data.msg || "请求失败")
                } 
            })
        },
        queryBandwidthData({commit}, condition){ 
            api.queryBandwidthData(condition.params).then(reply => { 
                if(reply.data.ok){
                    commit('QUERY_BANDWIDTH_DATA', reply.data.data); 
                    condition.cb && condition.cb(reply.data)  
                }else{
                    Message.error(reply.data.msg || "请求失败")
                } 
            })
        },
    },
    mutations: { 
        FETCH_CUSTOMER_RELATE_DOMAIN(state, data){
            state.customerRelatedomains = data
        }, 
        QUERY_BANDWIDTH_DATA(state, data){
            state.bandwidthDatas = data
        }
    }
}